package com.eagle.fulltextnews;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.http.*;

import com.eagle.gennewdata.model.WebSetting;
import com.eagle.gennewdata.untl.GloblasFun;

@SuppressWarnings("serial")
public class FulltextnewsServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/xml;charset=utf-8");
		resp.setHeader("Pragma", "No-cache");   
		resp.setHeader("Cache-Control", "no-cache");   
		resp.setDateHeader("Expires", 0); 
		Date dateNow = new Date();
		
		//(dateNow.getTime() - WebSetting.lGetDataTime) > 1000 * 60 &&
		if (req.getParameter("rssurl") != null) {
			WebSetting.lGetDataTime = dateNow.getTime();
			String strURL = "";
			
			int nPage = 1;
			
			if (req.getParameter("page") != null) 
				nPage = Integer.parseInt(req.getParameter("page").toString());
			
			strURL = req.getParameter("rssurl").toString();

			PrintWriter pWriter = resp.getWriter();
			for (int i = 1; i <= nPage; i++) 
				GloblasFun.parseRssURL(strURL, nPage);
			pWriter.write(dateNow.toString());
			pWriter.flush();
		}
	}
}
